/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bancoDeDados;

import java.sql.SQLException;
import regraDeNegocio.RNBemPatrimonial;

/**
 *
 * @author Gean
 */
public class BDBemPatrimonial {
    
    public void insertBD(RNBemPatrimonial bem) throws SQLException{
        Conexao c = new Conexao();
        
        if(!bem.getNotaFiscal().equals("")){
        c.insert("INSERT INTO bempatrimonial (descricao, cor, marca, numeroserie, plaqueta_numplaqueta, responsavel_siape, notafiscal, "
                + "idpredio, idsala) VALUES ('"+bem.getDescr()+"','"+bem.getCor()+"','"+bem.getMarca()+"','"+bem.getNumSerie()+"','"
                +bem.getPlaqueta()+"','"+bem.getResponsavel()+"','"+bem.getNotaFiscal()+"','"+bem.getPredio()+"','"+bem.getSala()+"')"); 
        
        c.insert("UPDATE plaqueta, bempatrimonial SET plaqueta.`SituacaoPlaq` = 'Em uso' WHERE plaqueta.`NumPlaqueta` = '"+bem.getPlaqueta()+"'");
        }else{
            c.insert("INSERT INTO bempatrimonial (descricao, cor, marca, numeroserie, plaqueta_numplaqueta, responsavel_siape, "
                + "idpredio, idsala) VALUES ('"+bem.getDescr()+"','"+bem.getCor()+"','"+bem.getMarca()+"','"+bem.getNumSerie()+"','"
                +bem.getPlaqueta()+"','"+bem.getResponsavel()+"','"+bem.getPredio()+"','"+bem.getSala()+"')");
        
        c.insert("UPDATE plaqueta, bempatrimonial SET plaqueta.`SituacaoPlaq` = 'Em uso' WHERE plaqueta.`NumPlaqueta` = '"+bem.getPlaqueta()+"'");
        }
   }
}
